import wx
import wx.html

class RobotBrowserCtrl(wx.html.HtmlWindow):
    def __init__(self, parent, id, *args, **kwargs):
        super(RobotBrowserCtrl, self).__init__(parent, id, *args, **kwargs)
        
    def Copy(self):
        '''Copy selected text to clipboard
        
        TODO: consider doing a "smart copy" where we put
        tsv data on the clipboard
        '''
        return self.SelectionToText()

    def CanCopy(self):
        '''Return True if there is selected text that can be copied'''
        if len(self.SelectionToText()) > 0:
            return True
        return False

    def Load(self, robot_object):
        html = "<table>\n"
        html += "<tr><td>Name:</td><td>%s</td></tr>\n" % robot_object.name
        html += "</table>\n"
        self.SetPage(html)
